var scene
var skyline
var skyline_polygonHandler
var widget



function skylineOnload() {

    scene = viewer.scene;
    skyline = new Cesium.Skyline(scene); //创建天际线分析对象
    skyline_polygonHandler = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Polygon);
    widget = viewer.cesiumWidget;
    $('#Skyline_chooseView').click(function() {
        var cartographic = scene.camera.positionCartographic;
        var longitude = Cesium.Math.toDegrees(cartographic.longitude);
        var latitude = Cesium.Math.toDegrees(cartographic.latitude);
        var height = cartographic.height;

        //天际线分析的视口位置设置成当前相机位置
        skyline.viewPosition = [longitude, latitude, height];
        //设置俯仰和方向
        skyline.pitch = Cesium.Math.toDegrees(scene.camera.pitch);
        skyline.direction = Cesium.Math.toDegrees(scene.camera.heading);
        skyline.radius = 10000; // 天际线分析半径设置为10000米
        skyline.build();
    })
    $("#Skyline_clear").click(function() {
        Skyline_clear()
    })

}

function Skyline_clear() {
    removeAllEntities();
    skyline.clear();
    skyline_polygonHandler.clear();
}